import 'package:amap_flutter_location/amap_flutter_location.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_rider/kit/tts_kit.dart';
import 'package:flutter_rider/routers/routers.dart';
import 'package:flutter_rider/main/page/splash_page.dart';
import 'package:flutter_rider/utils/handle_error_utils.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'app.dart';
import 'config.dart';
import 'package:event_bus/event_bus.dart';
import 'kit/loc_kit.dart';
import 'main/widgets/ui_constant.dart';
// import 'package:flutter_bugly/flutter_bugly.dart';

EventBus eventBus = EventBus();

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  App.init();
  SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarIconBrightness: Brightness.dark));
  AMapFlutterLocation.setApiKey(Config.androidAmapKey, Config.iOSAmapKey);
  AMapFlutterLocation.updatePrivacyShow(true, true);
  AMapFlutterLocation.updatePrivacyAgree(true);
  LocKit.instance.init();

  /// 异常处理
  handleError(() => runApp(const ProviderScope(child: MyApp())));

  // FlutterBugly.postCatchedException(() {
  //   // 如果需要 ensureInitialized，请在这里运行。
  //   // WidgetsFlutterBinding.ensureInitialized();
  //   runApp(const MyApp());
  //   FlutterBugly.init(
  //     androidAppId: Config.androidBuglyAppId,
  //     iOSAppId: Config.iOSBuglyAppId,
  //   );
  // });
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return 
       MaterialApp(
            title: "智行助手",
            navigatorKey: App.navigatorKey,
            theme: ThemeData(
                colorScheme: const ColorScheme.light(
              primary: UIColor.color_primary,
              secondary: UIColor.color_primary,
            )),
            home: Scaffold(
              backgroundColor: UIColor.color_main,
              body: SplashPage(),
            ),
            debugShowCheckedModeBanner: false,
            onGenerateRoute: Routes.router.generator,
          // )
    );
    
    
    
    }
}


